﻿using ERPSystem.Common.Domains.UserCommon;
using ERPSystem.Common.DTO;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using RBACWrite.API.Command.Roless;

namespace RBACWrite.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class RBACsController : ControllerBase
    {
        private readonly IMediator mediator;
        private readonly ILogger<RBACsController> _logger;

        public RBACsController(IMediator mediator)
        {
            this.mediator = mediator;
        }



        /// <summary>
        /// 角色添加
        /// </summary>
        /// <param name="enm"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result> RolesAdd(RolesCreateCommon enm)
        {
            var list = await mediator.Send(enm);
            return list;
        }

        /// <summary>
        /// 角色列表
        /// </summary>
        /// <param name="enm"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ResultPage<Roles>> RolesList([FromQuery] RolesListCommon enm)
        {
            var list = await mediator.Send(enm);
            return list;
        }
        /// <summary>
        /// 添加权限角色关联
        /// </summary>
        /// <param name="enm"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result> PermissionRolesCreate(PermissionRolesCreateCommon enm)
        {
            var list = await mediator.Send(enm);
            return list;
        }
    }
}
